package org.ikastola

import ikastola.Constants;

import java.util.Date;

class Course {
	
	String name
	String division
	Integer shift
	Integer deleted
	Date classCreated
	Date classUpdated
	List subjects
	
	static hasMany = [subjects: Subject]
	
    static constraints = {
		name blank: false 
		division inList: ['A','B','C','D','E']
		shift inList: [1, 2], blank: false //1: mañana, 2: tarde
		deleted inList: [0, 1]
		classCreated nullable: true
		classUpdated nullable: true
    }
	
	def static list() {
		return findAllByDeleted(Constants.NOT_DELETED)
	}
	
	def getShiftDescription() {
		if (shift == 1) {
			return 'Mañana'
		} else {
			return 'Tarde'
		}
	}
}
